package com.chis.jmdatatimer.comm;

import com.chis.jm.pojo.TdChiltransUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import redis.clients.jedis.ShardedJedis;

import java.util.List;

/**
 * @Description 查询单位变更
 * @Company zwx
 * @author CZJ
 * @version 2016/6/24
 */
public class RedisFindtransUnitTx implements TransactionJedis {
	/**日志*/
	private static Logger log = LogManager.getLogger(RedisFindtransUnitTx.class);
	/** 儿童编码 */
	private String childCode;
	/** 单位迁移管理表集合 */
	private List<TdChiltransUnit> oldTransUnit;

	public RedisFindtransUnitTx(String childCode) {
		this.childCode = childCode;
	}

	@Override
	public void run(ShardedJedis jedis) throws Exception {
		try {
			jedis.select(2);
			byte[] bytes = jedis.get(childCode.getBytes());
			oldTransUnit = (List<TdChiltransUnit>) JedisSerializeUtil.unserialize(bytes);
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			throw new Exception(e.getMessage());
		}
	}

	public List<TdChiltransUnit> getOldTransUnit() {
		return oldTransUnit;
	}
}
